﻿import QtQuick 2.11
//import QtQuick.Controls 1.4
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
import QtMultimedia 5.9

import com.leamus.gamedata 1.0

import "."
import "_Global"
import "_Global/Progress"
import "_Global/Button"
import "_Global/Line"
import "_Global/Popup"

import "Poke"
import "Player"
import "QuestionBox"

import "_Global/Global.js" as GlobalJS
import "GameJS.js" as GameJS

//import "Poke/Temp.js" as PokeClass
//import "gameCore.js" as GameCore


Item {

    //property alias msgBox: msgBox
    property var arrayPoke: new Array       //牌
    property var arrayPlayer: new Array     //玩家
    //property var arrayRenWu: new Array      //人物

    property var arrayLine: new Array       //线段

    property var mapQiPaiDui: new Object       //临时弃牌 数组

    property int nPlayerCount: 0
    property int nPlayerMaxCount: 0
    property int nPokeMaxCount: 0
    property int nMyID: -1

    //property int nQiPaiDuiShowedCount: 0 //弃牌堆内可视数


    signal s_buttonClicked(int type)  //按钮，对应GameCore的buttonClicked函数
    signal s_debugMsg(string msg)     //调试，发送给DebugWindow.qml的信息

    signal s_restartGame(int code)            //重新启动游戏(1是重新开始,2是继续下一单词)
    signal s_closeGameUI()            //关闭游戏界面,返回上一界面

    signal s_sendMessage(var msg)



    id: gameWindow
    objectName: "GameUI"
    //width: Global.gamePos.sizeWindow.width
    //height: Global.gamePos.sizeWindow.height

    focus: true
    //title: qsTr("英语杀")
    //visible: false
    //flags: Qt.FramelessWindowHint
    anchors.fill: parent



    //初始化,game.qml调用,只调用一次
    function initOnce(pokeMaxCount,playerMaxCount) {
        console.log("!GameUI InitOnce:", pokeMaxCount, playerMaxCount);

        nPokeMaxCount = pokeMaxCount;
        nPlayerMaxCount = playerMaxCount;

        var i;
        //console.debug(GameCore.strlist.length)
        //牌
        for(i = 0; i < nPokeMaxCount; i++) {
            tmpCreatePoke(i);

            arrayPoke[i].vUserData = i;

            arrayPoke[i].s_debugMessage.connect(s_debugMsg);
            //arrayPoke[i].s_aniFinished.connect(onPokeAniFinished)
            //console.debug(typeof(GameCore.pokeList),GameCore.pokeList)
            //console.debug(i)
            //console.debug(typeof(GameCore.pokeList[0]),GameCore.pokeList[0])
            //console.debug(typeof(GameCore.pokeList[0].flagsChanged),GameCore.pokeList[0].flagsChanged)

            arrayPoke[i].s_clicked.connect(GameCore.sl_qml_PokeClicked);
            arrayPoke[i].s_holdTriggered.connect(function(n) {
                rectPokeTips.text = _private.getPokeTips(GameCore.pokeList[n].value);
                rectPokeTips.anchors.bottom = arrayPoke[n].top;
                rectPokeTips.anchors.left = arrayPoke[n].left;
                rectPokeTips.visible = true;
            });

            setPokeImage(arrayPoke[i],GameCore.pokeList[i].value);

        }

        //玩家
        for(i = 0; i < playerMaxCount; i++) {
            tmpCreatePlayer(i);

            arrayPlayer[i].vUserData = i;


            //console.debug(i)
            arrayPlayer[i].s_clicked.connect(GameCore.sl_qml_PlayerClicked);

            arrayPlayer[i].pokeWeaponSmall.s_clicked.connect(GameCore.sl_qml_PokeClicked);
            //GameCore.sl_qml_PokeClicked);

            //敌人小判定图片
            arrayPlayer[i].arrayPanDingSmall.push(compPanDingSmall.createObject(arrayPlayer[i],{
                                                                                    x: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.x})
                                                                                    , y: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.y})
                                                                                    , width: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.width})
                                                                                    , height: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.height})
                                                                                }));
            arrayPlayer[i].arrayPanDingSmall.push(compPanDingSmall.createObject(arrayPlayer[i],{
                                                                                    x: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.x + Global.gamePos.mapPlayer.nPanDingSpacing})
                                                                                    , y: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.y})
                                                                                    , width: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.width})
                                                                                    , height: Qt.binding(function(){return Global.gamePos.mapPlayer.rectPanDing.height})
                                                                                }));

            arrayLine[i] = compLine.createObject(itemScale);
        }

        //小判定图片
        itemMyItems.arrayPanDingSmall.push(compPanDingSmall.createObject(itemMyItems,{
                                                                         x: Qt.binding(function(){return Global.gamePos.rectMyPanDing.x})
                                                                         , y: Qt.binding(function(){return Global.gamePos.rectMyPanDing.y})
                                                                         , width: Qt.binding(function(){return Global.gamePos.rectMyPanDing.width})
                                                                         , height: Qt.binding(function(){return Global.gamePos.rectMyPanDing.height})
                                                                            }));
        itemMyItems.arrayPanDingSmall.push(compPanDingSmall.createObject(itemMyItems,{
                                                                         x: Qt.binding(function(){return Global.gamePos.rectMyPanDing.x + Global.gamePos.nMyPanDingSpacing})
                                                                         , y: Qt.binding(function(){return Global.gamePos.rectMyPanDing.y})
                                                                         , width: Qt.binding(function(){return Global.gamePos.rectMyPanDing.width})
                                                                         , height: Qt.binding(function(){return Global.gamePos.rectMyPanDing.height})
                                                                            }));

        for(i = 0; i < 20; i++) {
            popupChoiceAreas.arrayShouPai[i] = compPoke.createObject(popupChoiceAreas,{
                                                                    "nFlags": PokeClass.Flag_Enable
                                                                    , "width": Qt.binding(function(){return Global.gamePos.paiWidth})
                                                                    , "height": Qt.binding(function(){return Global.gamePos.paiHeight})
                                                                    //, "bTemp": true
                                                                    //, "bEnable": true
                                                                    //, "bClicked": true
                                                                    , "z": (i + 1)/ 100
                                                                    , "bZhengMian": false
                                                                    , "bRectangularGlow": true
                                                                    , "bBiggerEnabled": true
                                                                });
            popupChoiceAreas.arrayShouPai[i].s_clicked.connect(GameCore.sl_qml_PokeClicked);
        }
        for(i = 0; i < 4; i++) {
            popupChoiceAreas.arrayZhuangBei[i] = compPoke.createObject(popupChoiceAreas,{
                                                                      "nFlags": PokeClass.Flag_Enable
                                                                      , "width": Qt.binding(function(){return Global.gamePos.paiWidth})
                                                                      , "height": Qt.binding(function(){return Global.gamePos.paiHeight})
                                                                      //, "bTemp": true
                                                                      //, "bEnable": true
                                                                      //, "bClicked": false
                                                                      , "z": (i + 1)/ 100
                                                                      , "bZhengMian": true
                                                                      , "bRectangularGlow": true
                                                                      , "bBiggerEnabled": true
                                                                  });
            popupChoiceAreas.arrayZhuangBei[i].s_clicked.connect(GameCore.sl_qml_PokeClicked);
        }
        for(i = 0; i < 2; i++) {
            popupChoiceAreas.arrayPanDing[i] = compPoke.createObject(popupChoiceAreas
                                                                ,{"nFlags": PokeClass.Flag_Enable
                                                                    , "width": Qt.binding(function(){return Global.gamePos.paiWidth})
                                                                    , "height": Qt.binding(function(){return Global.gamePos.paiHeight})
                                                                    //, "bTemp": true
                                                                    //, "bEnable": true
                                                                    //, "bClicked": false
                                                                    , "z": (i + 1)/ 100
                                                                    , "bZhengMian": true
                                                                    , "bRectangularGlow": true
                                                                    , "bBiggerEnabled": true
                                                                });
            popupChoiceAreas.arrayPanDing[i].s_clicked.connect(GameCore.sl_qml_PokeClicked);
        }


        /*
        for(i = 0; i < iWuJiangMaxCount; i++) {
            arrayRenWu[i] = wujiangComp.createObject(gameWindow,{"nFlags": PokeClass.Flag_Null});
            GameCore.wuJiangList[i].flagsChanged.connect(function(flags){arrayRenWu[i].nFlags = flags;})
        }

        GameCore.s_FlagMenus2.connect(function(ok,cancel,giveup){
            console.debug("flags menus!!!",typeof(ok),ok,ok == PokeClass.Flag_Enable)
            ok == PokeClass.Flag_Enable ? buttonOK.enabled = true : buttonOK.enabled = false;
            cancel == PokeClass.Flag_Enable ? buttonCancel.enabled = true : buttonCancel.enabled = false;
            giveup == PokeClass.Flag_Enable ? buttonGiveup.enabled = true : buttonGiveup.enabled = false;
        });

        GameCore.s_FlagMenus1.connect(function(ok,cancel,giveup){
            var test
            test = PokeClass.Flag_Enable

            console.debug("flags menus!!!",typeof(ok),ok,ok == PokeClass.Flag_Enable)
            console.debug("flags menus!!!",typeof(test),test,test == PokeClass.Flag_Enable)
            ok == PokeClass.Flag_Enable ? buttonOK.enabled = true : buttonOK.enabled = false;
            cancel == PokeClass.Flag_Enable ? buttonCancel.enabled = true : buttonCancel.enabled = false;
            giveup == PokeClass.Flag_Enable ? buttonGiveup.enabled = true : buttonGiveup.enabled = false;
        });*/


        //Game框架信号
        GameCore.s_GameInitFinished.connect(init);
        GameCore.s_GameBegin.connect(function() {
        });

        GameCore.s_Message.connect(function(str){msgBox.appendText(str);});
        GameCore.s_Debug.connect(s_debugMsg);


        //3个按钮
        GameCore.s_FlagMenus.connect(function(ok,cancel,giveup) {
            if(ok == PokeClass.Flag_Enable)buttonOK.bCacheEnabled = true;
            else buttonOK.bCacheEnabled = false;
            if(cancel == PokeClass.Flag_Enable)buttonCancel.bCacheEnabled = true;
            else buttonCancel.bCacheEnabled = false;
            if(giveup == PokeClass.Flag_Enable)buttonGiveup.bCacheEnabled = true;
            else buttonGiveup.bCacheEnabled = false;

            //buttonOK.enabled = ok;
            //buttonCancel.enabled = cancel;
            //buttonGiveup.enabled = giveup;
        });


        GameCore.s_ChoiceWuJiang.connect(function() {
            if(GameManager.platform == "debug")
                popupChoiceRenWu.show();
            else {
                //按性别自动选
                if(UserInfo.sex == 1)
                    GameCore.sl_qml_SelectedWuJiang(WuJiangClass.Value_LiLei);
                else
                    GameCore.sl_qml_SelectedWuJiang(WuJiangClass.Value_HanMeiMei);

            }
        });

        //GameCore.s_ShowShortMessage.connect(function(str){shortMsg.text = str;});
        GameCore.s_ShowChuPaiMessage.connect(function(str){textChuPaiMsg.text = str;});
        //GameCore.s_ShowWenTiMessage.connect(function(str){questionBox.message.text = str;});

        GameCore.s_StartChuPai.connect(function(player){progress.visible = true; progress.start(Global.config.nChuPaiDelay,false);});
        GameCore.s_StopChuPai.connect(function(player){progress.stop(); progress.visible = false;});

        //将缓存的数据刷新,防止闪烁
        //包括玩家,牌,技能,按钮,某个玩家选择框
        GameCore.s_RefreshAllFlags.connect(function(){
            refreshAllPlayersFlags();
            refreshAllPokesFlags();
            refreshAllJiNengFlags();

            //如果这次要显示/隐藏的 和 上次的不同
            if(popupChoiceAreas.nCachePlayerShowed != popupChoiceAreas.nPlayerShowed) {
                if(popupChoiceAreas.nCachePlayerShowed == -1)
                    hidePlayersArea();
                else
                    showPlayersPai(popupChoiceAreas.nCachePlayerShowed);
            }

            //刷新按钮
            buttonOK.enabled = buttonOK.bCacheEnabled;
            buttonCancel.enabled = buttonCancel.bCacheEnabled;
            buttonGiveup.enabled = buttonGiveup.bCacheEnabled;
        })
        GameCore.s_RefreshAllPokePosition.connect(function(){
            refreshAllPokesPosition(1);   //如果设置为false，则 自动调整宽度 失效
        })

        GameCore.s_ShowPlayersArea.connect(function(player){
            popupChoiceAreas.nCachePlayerShowed = player;    //记录到缓存
        });
        //GameCore.s_HidePlayersArea.connect(hidePlayersArea);

        //出牌结束,画线
        GameCore.s_ChuPaiOver.connect(_private.drawLines);

        //问题
        GameCore.s_Wenti.connect(function(obj,type,time){
            //if(type < 4 && type > -1) {     //显示答案
                //console.debug("qml准备显示问题...")
                questionBox.showQuestion(obj,type,time);
            //}
            //else {
                //timerPublic.interval = 1000
                //timerPublic.vParam = [obj,type] //给定参数
                //timerPublic.functionTrigger =    //给定函数
                //        function(param){questionBox.showQuestion(param[0],param[1])}
                //timerPublic.start()
            //}
        });

        GameCore.s_ContinualChoice.connect(questionBox.showContinualChoiceWordMove);
        GameCore.s_FastChoice.connect(questionBox.showFastChoiceWordMove);


        //QML信号
        myZhuangBei.s_clicked.connect(function(clicked, userData){   //装备信号
            //console.debug("clicked:",clicked,userData)
            GameCore.sl_qml_PokeClicked(clicked, userData);
        });

        questionBox.choiced.connect(GameCore.sl_UserActionFinished);   //问题框的信号
        s_buttonClicked.connect(GameCore.sl_qml_ButtonClicked);       //按钮信号
        //GameCore..connect(function(){})

        popupGameOver.levelChanged.connect(popupLevelChange.showBox);



        timerPublic.s_TimerPublic.connect(function(){
        });

        console.log("!GameUI InitOnce over!");
    }

    function showPlayerMsg(seatID,msg) {
        //console.debug("seatID:",seatID);
        arrayPlayer[seatID].showMsg(msg);
    }

    //根据玩家数设置 玩家坐标
    function setPlayersPos() {
        switch(nPlayerCount)
        {
        case 2:
            {
                //console.debug(arrayPlayer[nMyID].data.x);
                //console.debug(Global.gamePos.posPlayer0.x);

                arrayPlayer[nMyID].moveTo(Global.gamePos.listPosPlayer[0].pos.x,Global.gamePos.listPosPlayer[0].pos.y);
                arrayPlayer[(nMyID+1) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[4].pos.x,Global.gamePos.listPosPlayer[4].pos.y);
            }
            break;
        case 3:
            {
                arrayPlayer[nMyID].moveTo(Global.gamePos.listPosPlayer[0].pos.x,Global.gamePos.listPosPlayer[0].pos.y);
                arrayPlayer[(nMyID+1) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[3].pos.x,Global.gamePos.listPosPlayer[3].pos.y);
                arrayPlayer[(nMyID+2) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[5].pos.x,Global.gamePos.listPosPlayer[5].pos.y);

            }
            break;
        case 4:
            {
                arrayPlayer[nMyID].moveTo(Global.gamePos.listPosPlayer[0].pos.x,Global.gamePos.listPosPlayer[0].pos.y);
                arrayPlayer[(nMyID+1) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[2].pos.x,Global.gamePos.listPosPlayer[2].pos.y);
                arrayPlayer[(nMyID+2) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[4].pos.x,Global.gamePos.listPosPlayer[4].pos.y);
                arrayPlayer[(nMyID+3) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[6].pos.x,Global.gamePos.listPosPlayer[6].pos.y);
            }
            break;
        case 5:
            {
                arrayPlayer[nMyID].moveTo(Global.gamePos.listPosPlayer[0].pos.x,Global.gamePos.listPosPlayer[0].pos.y);
                arrayPlayer[(nMyID+1) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[1].pos.x,Global.gamePos.listPosPlayer[1].pos.y);
                arrayPlayer[(nMyID+2) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[3].pos.x,Global.gamePos.listPosPlayer[3].pos.y);
                arrayPlayer[(nMyID+3) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[5].pos.x,Global.gamePos.listPosPlayer[5].pos.y);
                arrayPlayer[(nMyID+4) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[7].pos.x,Global.gamePos.listPosPlayer[7].pos.y);
            }
            break;
        case 6:
            {
                arrayPlayer[nMyID].moveTo(Global.gamePos.listPosPlayer[0].pos.x,Global.gamePos.listPosPlayer[0].pos.y);
                arrayPlayer[(nMyID+1) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[1].pos.x,Global.gamePos.listPosPlayer[1].pos.y);
                arrayPlayer[(nMyID+2) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[3].pos.x,Global.gamePos.listPosPlayer[3].pos.y);
                arrayPlayer[(nMyID+3) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[4].pos.x,Global.gamePos.listPosPlayer[4].pos.y);
                arrayPlayer[(nMyID+4) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[5].pos.x,Global.gamePos.listPosPlayer[5].pos.y);
                arrayPlayer[(nMyID+5) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[7].pos.x,Global.gamePos.listPosPlayer[7].pos.y);
            }
            break;
        case 7:
            {
                arrayPlayer[nMyID].moveTo(Global.gamePos.listPosPlayer[0].pos.x,Global.gamePos.listPosPlayer[0].pos.y);
                arrayPlayer[(nMyID+1) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[1].pos.x,Global.gamePos.listPosPlayer[1].pos.y);
                arrayPlayer[(nMyID+2) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[2].pos.x,Global.gamePos.listPosPlayer[2].pos.y);
                arrayPlayer[(nMyID+3) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[3].pos.x,Global.gamePos.listPosPlayer[3].pos.y);
                arrayPlayer[(nMyID+4) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[5].pos.x,Global.gamePos.listPosPlayer[5].pos.y);
                arrayPlayer[(nMyID+5) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[6].pos.x,Global.gamePos.listPosPlayer[6].pos.y);
                arrayPlayer[(nMyID+6) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[7].pos.x,Global.gamePos.listPosPlayer[7].pos.y);
            }
            break;
        case 8:
            {
                arrayPlayer[nMyID].moveTo(Global.gamePos.listPosPlayer[0].pos.x,Global.gamePos.listPosPlayer[0].pos.y);
                arrayPlayer[(nMyID+1) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[1].pos.x,Global.gamePos.listPosPlayer[1].pos.y);
                arrayPlayer[(nMyID+2) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[2].pos.x,Global.gamePos.listPosPlayer[2].pos.y);
                arrayPlayer[(nMyID+3) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[3].pos.x,Global.gamePos.listPosPlayer[3].pos.y);
                arrayPlayer[(nMyID+4) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[4].pos.x,Global.gamePos.listPosPlayer[4].pos.y);
                arrayPlayer[(nMyID+5) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[5].pos.x,Global.gamePos.listPosPlayer[5].pos.y);
                arrayPlayer[(nMyID+6) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[6].pos.x,Global.gamePos.listPosPlayer[6].pos.y);
                arrayPlayer[(nMyID+7) % nPlayerCount].moveTo(Global.gamePos.listPosPlayer[7].pos.x,Global.gamePos.listPosPlayer[7].pos.y);
            }
            break;
        }
    }

    //刷新所有 牌 的位置，bForce:2为全部强制刷新;1为刷新位置不同的Poke和手牌区;
    function refreshAllPokesPosition(bForce) {
        if(nMyID == -1)  //游戏初始化时不用刷新
            return;

        //所有牌与牌区的宽度对比,重新排列
        //对比dx,如果不同则重新排列
        var dx = Math.floor(Global.gamePos.nShouPaiQuWidth / GameCore.playerList[nMyID].shouPaiList.length);
        //console.debug("刷新：",dx,Global.gamePos.rectPaiQu,Global.gamePos.rectPaiQu.width,GameCore.playerList[nMyID].shouPaiList.length)
        if(dx > Global.gamePos.paiWidth)
            dx = Global.gamePos.paiWidth;
        if(dx != Global.gamePos.shouPai_DX) {  //上次dx和这次dx不同
            Global.gamePos.shouPai_DX = dx;
            if(bForce != 2)bForce = 1;  //强制重新排列手牌

            //console.debug("强制重排：",dx);
            //console.debug("chongxinpailie:",GameJS.ShouPai_DX,dx,GameCore.playerList[nMyID].shouPaiList.length)
            //var j = 0;

            //for(i = 0; i < GameCore.playerList[nMyID].shouPaiList.length; i++) {
                //console.debug("move:",i,GameCore.playerList[nMyID].shouPaiList[i].id,GameJS.ShouPai_Pos[0] + dx * GameCore.playerList[nMyID].shouPaiList[i].positionValue)
            //    arrayPoke[GameCore.playerList[nMyID].shouPaiList[i].id].aniMoveTo(Global.gamePos.posShouPai.x + dx * GameCore.playerList[nMyID].shouPaiList[i].positionValue,Global.gamePos.posShouPai.y)
            //}
            /*
            for(var pai in GameCore.playerList[nMyID].shouPaiList) {
                console.debug(pai)
                setPokePos(pai,GameJS.ShouPai_Pos[0] + 50 * value,GameJS.ShouPai_Pos[1])
                console.debug(pai)
            }*/
        }


        var i = 0;
        for(; i < GameCore.pokeList.length; i++) {

            //if(arrayPoke[i].opacity == 0)
            //if(i == 70)
            //{
            //    console.debug(1)
            //}

            if(bForce == 2)
                updatePokePosition(i);

            //如果所有位置无变化
            else if(arrayPoke[i].nCachePositionArea == arrayPoke[i].nPositionArea
                    && arrayPoke[i].nCachePositionValue == arrayPoke[i].nPositionValue
                    && arrayPoke[i].nCachePositionPlayer == arrayPoke[i].nPositionPlayer
                    ) {
                //如果 是本人的手牌 (其他牌位置无变化也不需要强制刷新!)
                if(arrayPoke[i].nPositionPlayer == nMyID && arrayPoke[i].nPositionArea == PokeClass.Area_ShouPai) {  //&& bForce == 1
                    updatePokePosition(i);
                }
            }
            //位置有变化,则刷新
            else {
                /*
                console.debug(bForce,GameCore.pokeList[i].value)
                console.debug("~~~~~~",arrayPoke[i].nPositionArea,arrayPoke[i].nCachePositionArea)
                console.debug("~~~~~~",arrayPoke[i].nPositionValue, arrayPoke[i].nCachePositionValue)
                console.debug("~~~~~~",arrayPoke[i].nPositionPlayer, arrayPoke[i].nCachePositionPlayer)
                */
                updatePokePosition(i);
            }

            /*if(arrayPoke[i].nPositionPlayer == nMyID && arrayPoke[i].nPositionArea == PokeClass.Area_ShouPai) {
                console.debug("aaaaaaaaa:",bForce, arrayPoke[i].nPositionArea, arrayPoke[i].nCachePositionArea);
            }*/
        }
    }

    //游戏结束
    function overGame(ret) {
        _audio.stop();
        timerPublic.stop();



        var i;
        //for(i = 0; i < nPokeMaxCount; i++) {
            //arrayPoke[i].nFlags = PokeClass.Flag_Enable
            //arrayPoke[i].moveAni.stop()
            //arrayPoke[i].moveTo(0,0)
        //}
        for(i = 0; i < itemMyItems.arrayPanDingSmall.length; i++) {
            itemMyItems.arrayPanDingSmall[i].visible = false;
        }
        progress.stop();

        myZhuangBei.visible = false;

        buttonOK.enabled = buttonOK.bCacheEnabled = false;
        buttonCancel.enabled = buttonCancel.bCacheEnabled = false;
        buttonGiveup.enabled = buttonGiveup.bCacheEnabled = false;

        questionBox.hideQuestion();
        clearQiPaiQu();

        popupChoiceAreas.nCachePlayerShowed = popupChoiceAreas.nPlayerShowed = -1;
        hidePlayersArea();

        for(i = 0; i < nPlayerMaxCount; i++) {
            arrayPlayer[i].pokeWeaponSmall.visible = false;    //结束后必须全部隐藏
            for(var j = 0; j < arrayPlayer[i].arrayPanDingSmall.length; j++) {
                arrayPlayer[i].arrayPanDingSmall[j].visible = false;
            }
        }

        popupGameOver.createResult();
        popupGameOver.show();
        popupGameOver.focus = true;
    }


    function changeGameEscMenuVisible() {
        if(!gameEscMenu.visible) {
            gameEscMenu.show();
            gameEscMenu.focus = true;
        }
        else {
            gameEscMenu.hide();
            gameEscMenu.focus = false;
        }
        //console.debug("show???",gameEscMenu.visible)
    }

    function debugGameWindow(value, param) {   //调试窗口发过来的信息
        switch(value) {
        case 1:
            popupGameOver.show();
            break;
        }
    }



    Item {      //用来放大缩小
        id: itemScale
        x: 0
        y: 0
        anchors.fill: parent
        //scale: gameWindow.width / GameJS.GAMEWINDOW_WIDTH
        transformOrigin: Item.TopLeft

        Image { //背景图
            z: 0.01
            source: Global._FixResourcePath_R("Media/Images/Game/Back.png")
            //fillMode: Image.Tile
            anchors {
                fill: parent
            }
            MouseArea {
                anchors.fill: parent
            }
        }

        Image { //手牌区
            x: Global.gamePos.rectPaiQu.x
            y: Global.gamePos.rectPaiQu.y
            width: Global.gamePos.rectPaiQu.width
            height: Global.gamePos.rectPaiQu.height
            z: 0.10
            source: Global.resource.images.gameGame.hand
            anchors {
                //fill: parent
                //bottom: itemScale.bottom
            }
        }

        Image { //装备区
            id: imageMyZhuangBei
            x: Global.gamePos.rectMyZhuangBei.x
            y: Global.gamePos.rectMyZhuangBei.y
            width: Global.gamePos.rectMyZhuangBei.width
            height: Global.gamePos.rectMyZhuangBei.height
            z: 0.11
            source: Global._FixResourcePath_R("Media/Images/Game/Equip.png")
            anchors {
                //fill: parent
                //bottom: itemScale.bottom
            }
            Poke {
                id: myZhuangBei
                anchors.fill: parent
                visible: false
                bRectangularGlow: false
                bBiggerEnabled: true
            }

            //这里是边框效果
            RectangularGlow {
                visible: myZhuangBei.visible && myZhuangBei.bClicked
                anchors.fill: imageMyZhuangBei
                glowRadius: 3  //边框宽度
                spread: 0.3    //虚化程度(0~1)
                color: "red"  //颜色
                z: -1
                //cornerRadius: rect.radius + glowRadius
            }
        }

        Item {  //本玩家的物品
            id: itemMyItems
            z: 0.12
            property var arrayPanDingSmall: []  //compPanDingSmall列表,保存 判定图片
            property var arrayJiNeng: []   //compJiNeng列表,保存 技能控件

            Component {
                id: compJiNeng
                Poke {
                    //anchors.fill: parent
                    bRectangularGlow: true
                }
            }

            //根据Player的listJiNeng来初始化
            function initJiNeng() {
                var count = GameCore.playerList[nMyID].jiNengList.length;
                console.debug("initJiNeng",nMyID, count, GameCore.playerList[nMyID].jiNengList);

                //遍历JiNeng进行初始化
                var i;
                for(i = 0; i < count; i++)
                {
                    if(arrayJiNeng.length <= i) { //如果不够则创建
                        var jn = tmpBindJiNeng(i);
                        jn.s_clicked.connect(function(clicked,userData){  //绑定信号
                            GameCore.sl_qml_JiNengClicked(clicked, userData, nMyID);
                        });
                        arrayJiNeng.push(jn);
                    }
                    arrayJiNeng[i].pokeSource = getJiNengImage(GameCore.playerList[nMyID].jiNengList[i].value);
                    arrayJiNeng[i].visible = true;
                }

                //剩下的隐藏
                for(; i < arrayJiNeng.length; i++)
                {
                    arrayJiNeng[i].pokeSource = "";
                    arrayJiNeng[i].visible = false;
                }
            }
            function tmpBindJiNeng(i) {
                return compJiNeng.createObject(itemMyItems, {
                                            "x": Qt.binding(function(){return Global.gamePos.mapMyItems.rectJiNeng.x + i * Global.gamePos.mapMyItems.nJiNengDX;})
                                            ,"y": Qt.binding(function(){return Global.gamePos.mapMyItems.rectJiNeng.y;})
                                            ,"width": Qt.binding(function(){return Global.gamePos.mapMyItems.rectJiNeng.width;})
                                            ,"height": Qt.binding(function(){return Global.gamePos.mapMyItems.rectJiNeng.height;})
                                            ,"vUserData": i
                                        });
            }
            function getJiNengImage(value) {
                //console.debug("!!!!!!!!!!!jineng:",value)
                return Global._FixResourcePath_R("Media/Images/Game/JiNeng/JiNengErr.png");

                switch(value) {
                case PokeClass.Value_JiNeng_ZuoYongLi:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/ZuoYongLi.png");
                case PokeClass.Value_JiNeng_DaHangHaiShiDai:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/DaHangHaiShiDai.png");
                case PokeClass.Value_JiNeng_DuXiu:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/YaLiShanDa.png");
                case PokeClass.Value_JiNeng_ShenQu:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/ShenQu.png");
                case PokeClass.Value_JiNeng_MengGuDiGuo:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/MengGuDiGuo.png");
                case PokeClass.Value_JiNeng_ZhanZhengZhiShen:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/ZhanZhengZhiShen.png");
                case PokeClass.Value_JiNeng_MengNaLiSha:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/MengNaLiSha.png");
                case PokeClass.Value_JiNeng_KaiSa:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/KaiSa.png");
                case PokeClass.Value_JiNeng_AYuWang:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/AYuWang.png");
                case PokeClass.Value_JiNeng_JunShiTanDing:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/JunShiTanDing.png");
                default:
                    return Global._FixResourcePath_R("Media/Images/Game/JiNeng/JiNengErr.png");
                }
            }
        }

/*
        Image { //头像
            x: Global.gamePos.mapPlayer.sizePlayerAvatar.x
            y: Global.gamePos.mapPlayer.sizePlayerAvatar.y
            width: Global.gamePos.mapPlayer.sizePlayerAvatar.width
            height: Global.gamePos.mapPlayer.sizePlayerAvatar.height
            z: 0.03
            fillMode: Image.Tile
            source: Global._FixResourcePath_R("Media/System/dashboard-avatar.png")
            anchors {
                //fill: parent
                //bottom: itemScale.bottom
            }
        }*/

        /*
        Image {
            x: Global.gamePos.sizeWindow.width - 274
            y: Global.gamePos.rectPaiQu.y
            z: 0.04
            source: Global._FixResourcePath_R("Media/System/platter/bg.png")
            anchors {
                //fill: parent
                //bottom: itemScale.bottom
            }
*/

        //3个按钮
        ImageButton {
            property bool bCacheEnabled

            id: buttonOK
            x: Global.gamePos.mapButtons.rectOK.x
            y: Global.gamePos.mapButtons.rectOK.y
            width: Global.gamePos.mapButtons.rectOK.width
            height: Global.gamePos.mapButtons.rectOK.height
            z: 0.20
            //z: 0.2
            onButtonClicked: {
                //console.debug(GameCore.Game_Button_OK);
                s_buttonClicked(GameClass.Game_Button_OK);
            }
            onEnabledChanged: {
                //if(enabled)visible = true;
                //else visible = false;
            }

            Component.onCompleted: {
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Confirm/Normal.png"),0);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Confirm/Hover.png"),1);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Confirm/Normal.png"),2);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Confirm/Disabled.png"),3);
            }
        }

        ImageButton {
            property bool bCacheEnabled
            id: buttonCancel
            x: Global.gamePos.mapButtons.rectCancel.x
            y: Global.gamePos.mapButtons.rectCancel.y
            width: Global.gamePos.mapButtons.rectCancel.width
            height: Global.gamePos.mapButtons.rectCancel.height
            z: 0.21
            //z: 0.2
            onButtonClicked: {
                //console.debug(GameCore.Game_Button_Cancel);
                s_buttonClicked(GameClass.Game_Button_Cancel);
            }
            onEnabledChanged: {
                //if(enabled)visible = true;
                //else visible = false;
            }

            Component.onCompleted: {
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Cancel/Normal.png"),0);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Cancel/Hover.png"),1);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Cancel/Normal.png"),2);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Cancel/Disabled.png"),3);
            }
        }
        ImageButton {
            property bool bCacheEnabled
            id: buttonGiveup
            x: Global.gamePos.mapButtons.rectGiveup.x
            y: Global.gamePos.mapButtons.rectGiveup.y
            width: Global.gamePos.mapButtons.rectGiveup.width
            height: Global.gamePos.mapButtons.rectGiveup.height
            z: 0.22
            //z: 0.2
            onButtonClicked: {
                //console.debug(PokeClass.Type_Button,PokeClass.Flag_Clicked);
                //console.debug(GameCore.Game_Button_Giveup);
                s_buttonClicked(GameClass.Game_Button_Giveup);

            }
            onEnabledChanged: {
                //if(enabled)visible = true;
                //else visible = false;
            }

            Component.onCompleted: {
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Discard/Normal.png"),0);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Discard/Hover.png"),1);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Discard/Normal.png"),2);
                addImage(Global._FixResourcePath_R("Media/Images/Game/Buttons/Discard/Disabled.png"),3);
            }
        }

        //信息框
        MsgBox {
            id: msgBox
            x: Global.gamePos.rectMsgBox.x
            y: Global.gamePos.rectMsgBox.y
            width: Global.gamePos.rectMsgBox.width
            height: Global.gamePos.rectMsgBox.height
            textArea.font.pixelSize: Global.dpH(16)
            textArea.readOnly: true
            textArea.enabled: false
            z: 0.30

            /*anchors {
                top: parent.top
                right: parent.right
                rightMargin: 0
            }*/
            //enabled: false
            //textArea.verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
            //textArea.horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff

            Component.onCompleted: {
            }
        }


/*
        Text {
            id: shortMsg
            x: Global.gamePos.posShortMessage.x
            y: Global.gamePos.posShortMessage.y
            z: 0.2
            width: 200
            text: "准备开始...";
            font.pixelSize: 24;
            style: Text.Outline;
            styleColor: "yellow"
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
        }
*/
        //出牌信息
        Text {
            id: textChuPaiMsg
            x: Global.gamePos.rectChuPaiMessage.x
            y: Global.gamePos.rectChuPaiMessage.y
            width: Global.gamePos.rectChuPaiMessage.width
            height: Global.gamePos.rectChuPaiMessage.height
            z: 0.31
            text: "准备开始"
            font {
                //family: Global.resource.fonts.font1.name
                pixelSize: Global.gamePos.nChuPaiMsgFontSize
            }
            style: Text.Outline
            styleColor: "white"
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
        }

        Progress {
            id: progress
            x: Global.gamePos.rectProgress.x
            y: Global.gamePos.rectProgress.y
            width: Global.gamePos.rectProgress.width
            height: Global.gamePos.rectProgress.height
            z: 0.32
            visible: false
            imageProgressBack {
                source: Global.resource.images.gameGame.progress0
                /*
                border.left:
                    switch(Global.resolution) {
                        case 1:
                            return 10;
                        case 2:
                            return 10;
                    }
                border.right:
                    switch(Global.resolution) {
                        case 1:
                            return 10;
                        case 2:
                            return 10;
                    }
                    */
                //border.left: Global.dpW(10)
                //border.right: Global.dpW(10)
                //border.top: 5
                //border.bottom: 5
            }
            imageProgressFront {
                source: Global.resource.images.gameGame.progress1
                /*
                border.left:
                    switch(Global.resolution) {
                        case 1:
                            return 10;
                        case 2:
                            return 10;
                    }
                border.right:
                    switch(Global.resolution) {
                        case 1:
                            return 10;
                        case 2:
                            return 10;
                    }
                    */
                //border.left: Global.dpW(10)
                //border.right: Global.dpW(10)
                //border.top: 5
                //border.bottom: 5
            }
            onTimeUp: {
                s_buttonClicked(-1)
            }
        }

        QuestionBox {
            id: questionBox
            x: Global.gamePos.mapQuestionBox.rectBox.x
            y: Global.gamePos.mapQuestionBox.rectBox.y
            innerWidth: Global.gamePos.mapQuestionBox.rectBox.width
            innerHeight: Global.gamePos.mapQuestionBox.rectBox.height
            //width: {return Global.gamePos.rectQuestionBox.width}
            //height: {return Global.gamePos.rectQuestionBox.height}
            z: 100
            //color: Qt.rgba(0.5,0.5,0.5,0.9)
            //color: "#700090FF"
            color: "#00FFFFFF"
            visible: false
            animationType: "fade"
            easingType: Easing.Linear
            duration: 200

            /*anchors {
                verticalCenter: itemScale.verticalCenter
                horizontalCenter: itemScale.horizontalCenter
                horizontalCenterOffset: -Global.gamePos.sizeMsgBox.width/2
            }*/

            showMask: false
            maskParent: itemScale
            maskColor: "black"
            maskOpacity: 0.5

            /*
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    //console.debug("width,height:",questionBox.width,questionBox.height)
                    //console.debug("width2,height2:",Global.gamePos.rectQuestionBox.width
                    //              ,Global.gamePos.rectQuestionBox.height)
                    //console.debug("width3,height3:",Global.gamePos.mapChoiceAreas.rectChoiceAreas.width
                    //              ,Global.gamePos.mapChoiceAreas.rectChoiceAreas.height)
                }
            }*/

        }


        //牌的提示
        Rectangle {
            property alias text: textPokeTips.text

            id: rectPokeTips
            z: 100
            //width: Global.gamePos.sizePokeTips.width
            //height: Global.gamePos.sizePokeTips.height
            //width: textPokeTips.paintedWidth
            //height: textPokeTips.paintedHeight
            width: Global.gamePos.sizePokeTips.width
            height: textPokeTips.contentHeight
            visible: false
            color: "#80000000"

            //牌提示
            Text {
                id: textPokeTips
                textFormat: Text.RichText
                wrapMode: Text.WordWrap
                //readOnly: true
                enabled: false
                color : "#FFFFFF"
                width: parent.width

                text: ""

                //font.family: ""
                //font.bold: true
                font.pixelSize: Global.gamePos.nPokeTipsFontSize

            }

        }


        //某个玩家的 所有牌 的 选择框
        Popup {
            property int nPlayerShowed: -1  //上次显示的玩家,-1是没有
            property int nCachePlayerShowed: -1  //要显示的玩家的缓存
            property var arrayShouPai: []
            property var arrayZhuangBei: []
            property var arrayPanDing: []
            //opacity: 0.3

            id: popupChoiceAreas
            //x: 200; y: 180
            z: GameJS.Z_ChoiceAreas
            x: Global.gamePos.mapChoiceAreas.rectChoiceAreas.x
            y: Global.gamePos.mapChoiceAreas.rectChoiceAreas.y
            innerWidth: Global.gamePos.mapChoiceAreas.rectChoiceAreas.width
            innerHeight: Global.gamePos.mapChoiceAreas.rectChoiceAreas.height
            //color: Qt.rgba(0.5,0.5,0.5,0.9)
            //color: "#700090FF"
            //color: "#A0FFFFFF"
            color: "#00FFFFFF"
            visible: false
            showMask: false
            animationType: "fade"
            easingType: Easing.Linear
            duration: 200
            Image {
                id: imageChoiceArea
                source: Global.resource.images.gameGame.choiceArea
                anchors.fill: parent
            }

            /*anchors {
                verticalCenter: itemScale.verticalCenter
                horizontalCenter: itemScale.horizontalCenter
                horizontalCenterOffset: -Global.gamePos.sizeMsgBox.width/2
            }*/

            //maskParent: itemScale
            //maskColor: "black"
            //maskOpacity: 0.5

        }

        ImageButton2 {  //游戏退出按钮
            id: imageReturn
            x: Global.dpW(0)
            y: Global.dpH(0)
            z: 150
            width: Global.dpW(100)
            height: Global.dpH(78)

            source: Global._FixResourcePath_R("Media/Images/Return.png")

            soundEffectClick: Global.resource.effects.effectButton
            bEffectOn: Global.config.bEffectOn

            onButtonClicked: {
                changeGameEscMenuVisible();
            }
        }

        ImageButton2 {  //聊天
            id: imageMsg
            x: Global.dpW(0)
            y: Global.dpH(122)
            z: 150
            width: Global.dpW(156)
            height: Global.dpH(122)
            visible: false

            source: Global._FixResourcePath_R("Media/Images/Return.png")
            onButtonClicked: {
                imageWriteMsg.visible = true;
                textMessage.focus = true;
            }
        }

        Item {  //聊天板块
            id: imageWriteMsg
            x: Global.dpW(0)
            y: Global.dpH(244)
            z: 150
            visible: false

            TextArea {
                id: textMessage
                font.pixelSize: Global.dpH(30)
                wrapMode: TextEdit.Wrap
                background: Rectangle {
                    color: "white"
                    //implicitWidth: 1
                    //implicitHeight: 1
                    //border.color: control.enabled ? "#21be2b" : "transparent"

                }
                selectByMouse: true
            }

            ImageButton2 {  //发送
                id: imageSend
                x: Global.dpW(156)
                y: Global.dpH(122)
                z: 150
                width: Global.dpW(156)
                height: Global.dpH(122)

                source: Global._FixResourcePath_R("Media/Images/Return.png")
                onButtonClicked: {
                    imageWriteMsg.visible = false;
                    itemScale.focus = true;
                    if(textMessage.text != "") {
                        showPlayerMsg(nMyID, textMessage.text);
                        s_sendMessage(textMessage.text);
                        textMessage.text = "";
                    }
                }
            }
        }

        GameChoiceRenWu {
            id: popupChoiceRenWu
            z: 160
            anchors.fill: parent
            visible: false

            Connections {
                target: popupChoiceRenWu
                onChoiceRenWu: {
                    //console.debug("!!!!!!choiceRenWu:",rw);
                    popupChoiceRenWu.hide();
                    GameCore.sl_qml_SelectedWuJiang(rw);
                    itemMyItems.initJiNeng();

                    /*//按性别自动选
                    if(UserInfo.sex == 1)
                        GameCore.sl_qml_SelectedWuJiang(WuJiangClass.Value_LiLei);
                    else
                        GameCore.sl_qml_SelectedWuJiang(WuJiangClass.Value_HanMeiMei);
                        */
                }
            }
        }

        //游戏结束窗口(200以上)
        GameOver {
            id: popupGameOver
            radius: 10
            z: 200
            visible: false
            color: "#00000000"

            x: Global.gamePos.mapGameOver.rectGameOver.x
            y: Global.gamePos.mapGameOver.rectGameOver.y
            innerWidth: Global.gamePos.mapGameOver.rectGameOver.width
            innerHeight: Global.gamePos.mapGameOver.rectGameOver.height
            /*anchors {
                verticalCenter: itemScale.verticalCenter
                horizontalCenter: itemScale.horizontalCenter
            }*/

            maskParent: itemScale

            /*
            Keys.onEscapePressed:  {
                event.accepted = true;
                changeGameEscMenuVisible();
                /*
                if (event.key == Qt.Key_Left) {
                    console.log("move left");
                    event.accepted = true;
                }
                * /
                //gameWindow.s_closeGameUI()
                //popupGameOver.close()

            }*/

            onRestartGame: {
                gameWindow.s_restartGame(0);
            }

            onCloseGameUI: {
                gameWindow.s_closeGameUI();
            }
        }

        //等级变化窗口
        Popup {
            id: popupLevelChange
            //color: "#00000000"
            visible: false
            z: 210

            animationType: "size"           //出现动画类型
            duration: 1000                  //动画时间
            easingType: Easing.OutElastic   //动画效果
            bDrag: false

            x: Global.gamePos.rectLevelBox.x
            y: Global.gamePos.rectLevelBox.y
            innerWidth: Global.gamePos.rectLevelBox.width
            innerHeight: Global.gamePos.rectLevelBox.height

            Image { //升降级图标
                id: imageLevelBack
                //source: Global._FixResourcePath_R("Media/Images/Game/GameOver/Back.png")
                anchors.fill: parent
            }

            Image { //等级图标
                id: imageLevel
                source: Global._FixResourcePath_R(qsTr("Media/Images/Levels/%1.png").arg(Global.userInfo.userLevel))
                x: Global.dpW(830)
                y: Global.dpH(630)
                width: Global.dpW(260)
                height: Global.dpH(90)
            }

            Timer {
                id: timerlevelChangeShow
                interval: 3000
                repeat: false
                onTriggered: {
                    popupLevelChange.hide();
                }
            }

            function showBox(type) {
                if(type == true)
                    imageLevelBack.source = Global._FixResourcePath_R("Media/Images/Game/GameOver/LevelUp.png");
                else
                    imageLevelBack.source = Global._FixResourcePath_R("Media/Images/Game/GameOver/LevelDown.png");
                popupLevelChange.show();
                timerlevelChangeShow.start();
            }
        }

        //Esc菜单
        GameEscMenu {
            id: gameEscMenu
            x: Global.gamePos.mapGameEscMenu.rectBack.x
            y: Global.gamePos.mapGameEscMenu.rectBack.y
            innerWidth: Global.gamePos.mapGameEscMenu.rectBack.width
            innerHeight: Global.gamePos.mapGameEscMenu.rectBack.height

            radius: 10
            z: 300

            visible: false
            //anchors.centerIn: parent

            /*anchors {
                verticalCenter: itemScale.verticalCenter
                horizontalCenter: itemScale.horizontalCenter
            }*/

            maskParent: itemScale

            //onContinueGame: {
            //    gameEscMenu.hide();
            //}

            onRestartGame: {
                gameWindow.s_restartGame(2);
            }

            onTerminateGame: {
                GameManager.sl_qml_TerminateGame(code);
            }
        }

    }

    /*
    ImageButton {
        id: buttonOK2
        x: 100
        y: 100
        z: 0.2
        onButtonClicked: {
            //console.debug(GameCore.Game_Button_OK);
            s_buttonClicked(10)
        }
        Component.onCompleted: {
            addImage("Image/OK/normal.png",0)
            addImage("Image/OK/hover.png",1)
            addImage("Image/OK/down.png",2)
            addImage("Image/OK/disabled.png",3)
        }
    }

    ImageButton {
        id: buttonOK3
        x: 200
        y: 100
        z: 0.2
        onButtonClicked: {
            //console.debug(GameCore.Game_Button_OK);
            s_buttonClicked(11)
        }
        Component.onCompleted: {
            addImage("Image/OK/normal.png",0)
            addImage("Image/OK/hover.png",1)
            addImage("Image/OK/down.png",2)
            addImage("Image/OK/disabled.png",3)
        }
    }
    */

    //线条隐藏使用的时间器
    Timer {
        id: timerLineHide
        interval: 1200
        repeat: false
        onTriggered: {
            for(var j = 0; j < gameWindow.nPlayerCount; j++) {
                arrayLine[j].visible = false;
            }
            //convas.visible = true;
            //convas.paint(convas.canvasSized)
            //convas.requestPaint()
            //convas.markDirty(Qt.rect(convas.x,convas.y,convas.width,convas.height))
            //convas.markDirty(Qt.rect(0,0,500,500))
            //convas.paint(Qt.rect(convas.x,convas.y,convas.width,convas.height))

        }
    }



    Audio {
        id : _audio
        //source: Global._FixLocalPath_R("Media/Sounds/Music/back1.mp3")
        //loops: Audio.Infinite
        playlist: Playlist {
            id: playlist
            playbackMode: Playlist.Random
        }
        volume: 0.7
        Component.onCompleted: {
            playlist.addItem(Qt.resolvedUrl(Global._FixLocalPath_R("Media/Sounds/Music/music1.mp3")));
            playlist.addItem(Qt.resolvedUrl(Global._FixLocalPath_R("Media/Sounds/Music/music2.wma")));
            playlist.addItem(Qt.resolvedUrl(Global._FixLocalPath_R("Media/Sounds/Music/music3.mp3")));
            playlist.addItem(Qt.resolvedUrl(Global._FixLocalPath_R("Media/Sounds/Music/music4.mp3")));
            //playlist.addItem(Qt.resolvedUrl(Global._FixLocalPath_R("Media/Sounds/Music/music5.wma")))
        }
    }



    Timer { //带参时间器,可调用自定义函数
        property var vParam: null        //函数的参数
        property var functionTrigger    //到时候触发的函数(动态给定函数内容)

        id: timerToTriggerFunction
        interval: 1000
        repeat: false
        onTriggered: functionTrigger(vParam)
    }

    Timer { //公用时间器
        signal s_TimerPublic()

        id: timerPublic
        interval: 1000
        repeat: true
        onTriggered: s_TimerPublic()
    }


    Component {
        id: compPoke
        Poke {
            //id: cPoke
            //property int iUsedPlayer: -1    //保存上次 装备 和 判定牌 临时变量(玩家id)
            //property int iUsedPosition: -1    //保存上次 判定牌小图数组 的位置(下标)
            //property int iUsedPositionValue: -1    //保存上次 判定牌小图数组 的位置(下标)

            property bool bIsMine: false    //是否是本人手牌（貌似暂时没用)

            //目前的位置信息
            property int nPositionArea
            property int nPositionValue
            property int nPositionPlayer

            //缓存最新的信息(需要刷新)
            property int nCachePositionArea
            property int nCachePositionValue
            property int nCachePositionPlayer
            property int nCacheFlags

            //bRectangularGlow: true

            //mouseArea.onEntered: if(bEnable){scale = 1.03; z += 1;}
            mouseArea.onExited: {
                //if(bEnable){scale = 1; z -= 1;}
                rectPokeTips.visible = false;
            }
        }
    }

    Component {
        id: compPlayer
        Player {
            id: tmpPlayer

            function showMsg(msg) {
                textMsg.text = msg;
                rectPlayerMsg.visible = true;
                timerMsg.restart();
            }

            //缓存最新的信息(需要刷新)
            property int nCacheFlags

            //property alias pokeWeaponSmall: pokeWeaponSmall   //
            property var arrayPanDingSmall: [] //判定小图标

            property Poke pokeWeaponSmall:
            Poke {  //武器图标
                //id: pokeWeaponSmall
                x: Global.gamePos.mapPlayer.rectZhuangBei.x
                y: Global.gamePos.mapPlayer.rectZhuangBei.y
                width: Global.gamePos.mapPlayer.rectZhuangBei.width
                height: Global.gamePos.mapPlayer.rectZhuangBei.height
                z: GameJS.Z_Player + 1
                //width: 102
                //height: 12
                visible: false
                bRectangularGlow: true
                parent: tmpPlayer
                //pokeSource: "1.jpg"
            }

            //聊天框
            Rectangle {
                id: rectPlayerMsg
                anchors.fill: parent
                color: "white"
                visible: false

                Text {  //聊天内容
                    id: textMsg
                    font.pixelSize: Global.dpH(35)
                    anchors.fill: parent
                    wrapMode: Text.WordWrap

                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }

                Timer { //关闭倒计时
                    id: timerMsg
                    interval: 5000
                    repeat: false
                    onTriggered: {
                        textMsg.text = "";
                        rectPlayerMsg.visible = false;
                    }
                }
            }

        }
    }
/*
    Component {
        id: compPanDingSmall
        Image {
            //width: 10
            //height: 10
            visible: false
            //color: "white"
        }
    }*/

    Component {
        id: compPanDingSmall
        Poke {  //武器图标
            //x: 22
            //y: 94
            //width: 102
            //height: 12
            visible: false
            bRectangularGlow: false
            //pokeSource: "1.jpg"
        }
    }

    Component {
        id: compLine
        Line {
            width: Global.dpW(7)
            color: "#00000000"
            source: Global._FixResourcePath_R("Media/Images/Game/Line.png")
            lineAni.duration: 800
            z: GameJS.Z_Line
        }
    }

    //设置牌的flags
    function setPokeFlags(i,flags) {
        //arrayPoke[i].nCacheFlags = flags;
        //console.debug("PokeFlags:",arrayPoke[0].id)
        //console.debug("setPokeFlags:",i,flags)
    }
    //刷新牌的flags
    function updatePokeFlags(i) {
        arrayPoke[i].nFlags = GameCore.pokeList[i].flags;
    }
    //刷新所有牌的flags
    function refreshAllPokesFlags() {
        var i = 0;
        for(; i < nPokeMaxCount; i++) {
            updatePokeFlags(i);
        }
    }


    //刷新所有技能flags(iMyID的)
    function refreshAllJiNengFlags() {
        //遍历JiNeng
        var i;
        //console.debug("length:",nMyID,itemMyItems.arrayJiNeng,GameCore.playerList[nMyID].jiNengList.length);
        for(i = 0; i < GameCore.playerList[nMyID].jiNengList.length; i++) {
            //console.debug(":",i);
            itemMyItems.arrayJiNeng[i].nFlags = GameCore.playerList[nMyID].jiNengList[i].flags;
        }
    }

    //设置玩家flags
    function setPlayerFlags(i,flags) {
        //console.debug("setplayerFlag:",i,flags);
        //arrayPlayer[i].nCacheFlags = flags;
    }
    //刷新玩家flags
    function updatePlayerFlags(i) {
        arrayPlayer[i].nFlags = GameCore.playerList[i].flags;
    }
    function refreshAllPlayersFlags() {
        var i = 0;
        for(; i < nPlayerCount; i++) {
            updatePlayerFlags(i);
        }
    }

    //设置玩家坐标
    function setPlayerPos(i,x,y) {
        arrayPlayer[i].x = x;
        arrayPlayer[i].y = y;
    }

    //设置牌的坐标(只是缓存中)
    function setPokePosition(i,area,value,player) {
        //console.debug("测试!!!!!!!!!!!!!! ",i)
        arrayPoke[i].nCachePositionArea = area;
        arrayPoke[i].nCachePositionValue = value;
        arrayPoke[i].nCachePositionPlayer = player;

    }

    //!!刷新i牌的位置到area，value，player
    function updatePokePosition(i) {
        var area = arrayPoke[i].nCachePositionArea;
        var value = arrayPoke[i].nCachePositionValue;
        var player = arrayPoke[i].nCachePositionPlayer;

        /*  //相当于强制刷新位置
        if(area == arrayPoke[i].nPositionArea
                && value == arrayPoke[i].nPositionValue
                && player == arrayPoke[i].nPositionPlayer)
            return;*/

        //如果此牌上次被装备到某个玩家的装备或判定,则先取消
        //if(arrayPoke[i].iUsedPlayer != player) {
        //if(arrayPoke[i].nPositionArea == PokeClass.Area_ZhuangBei || arrayPoke[i].nPositionArea == PokeClass.Area_PanDing)
            refreshSmallZhuangBeiOrPanDing(i,area,value,player);
        //    arrayPoke[i].iUsedPlayer = player
        //}
        //console.debug("~~~~~~",arrayPoke[i].nPositionArea,arrayPoke[i].nCachePositionArea)
        //console.debug("~~~~~~",arrayPoke[i].nPositionValue, arrayPoke[i].nCachePositionValue)
        //console.debug("~~~~~~",arrayPoke[i].nPositionPlayer, arrayPoke[i].nCachePositionPlayer)

        switch(area) {
        case PokeClass.Area_ShouPai:
            if(player == nMyID) {    //玩家本人,则显示手牌
                arrayPoke[i].bZhengMian = true;
                arrayPoke[i].bIsMine = true;
                //arrayPoke[i].visible = true
                arrayPoke[i].aniOpacity(1,0);
                //arrayPoke[i].aniOpacity(0,1);
                arrayPoke[i].z = GameJS.Z_ShouPai + value / 100;

                if(arrayPoke[i].nFlags & PokeClass.Flag_Clicked)
                    arrayPoke[i].aniMoveTo(Global.gamePos.posShouPai.x + Global.gamePos.shouPai_DX * value, Global.gamePos.posShouPai.y - Global.gamePos.shouPai_DY);
                else
                    arrayPoke[i].aniMoveTo(Global.gamePos.posShouPai.x + Global.gamePos.shouPai_DX * value, Global.gamePos.posShouPai.y);

                //console.debug("手牌",arrayPoke[i].nFlags);
                //console.debug(i,arrayPoke[i].x,arrayPoke[i].y,arrayPoke[i].z,arrayPoke[i].visible)
            }
            else {
                if(area != arrayPoke[i].nPositionArea
                                || player != arrayPoke[i].nPositionPlayer)
                {
                    //console.debug("id::::",player,nMyID)
                    arrayPoke[i].bZhengMian = false;
                    arrayPoke[i].bIsMine = false;
                    arrayPoke[i].aniMoveTo(arrayPlayer[player].x + (Global.gamePos.mapPlayer.sizePlayerAvatar.width - Global.gamePos.paiWidth) / 2
                                           , arrayPlayer[player].y + (Global.gamePos.mapPlayer.sizePlayerAvatar.height - Global.gamePos.paiHeight) / 2)

                    arrayPoke[i].aniOpacity(1,0);
                    //arrayPoke[i].aniOpacity(0,1);
                    arrayPoke[i].delayHide(Global.config.nPaiDelayHide);

                    //console.debug("这句2:",i)
                    arrayPoke[i].z = GameJS.Z_ShouPai + value / 100;
                    //arrayPoke[i].visible = false
                }
            }
            break;
        case PokeClass.Area_ZhuangBei:
            arrayPoke[i].bZhengMian = true;
            arrayPoke[i].bIsMine = false;
            //console.debug("这句1:",i)
            //arrayPoke[i].visible = true
            arrayPoke[i].z = GameJS.Z_ShouPai + value / 100;

            if(!(area == arrayPoke[i].nPositionArea
                    && value == arrayPoke[i].nPositionValue
                    && player == arrayPoke[i].nPositionPlayer)) {   //准备
                createPokeToQiPaiDui(i);
                if(Global.config.bEffectOn)Global.resource.effects.effectWeapon.play();
            }

            arrayPoke[i].aniOpacity(0,0);
            arrayPoke[i].moveTo(arrayPlayer[player].x, arrayPlayer[player].y);
            //arrayPoke[i].aniMoveTo(arrayPlayer[player].x, arrayPlayer[player].y);
            //arrayPoke[i].aniMoveTo(Global.gamePos.posQiPaiDui.x, Global.gamePos.posQiPaiDui.y);
            if(arrayPoke[i].nPositionArea != PokeClass.Area_ZhuangBei) {
                //arrayPoke[i].aniOpacity(1,0);
                //arrayPoke[i].aniOpacity(0,1);
                //arrayPoke[i].delayHide(500);
            }
            //refreshSmallZhuangBeiOrPanDing(i,area,value,player)
            //arrayPoke[i].iUsedPlayer = player;
            break;
        case PokeClass.Area_PanDing:
            arrayPoke[i].bZhengMian = true;
            arrayPoke[i].bIsMine = false;
            arrayPoke[i].z = GameJS.Z_ShouPai + value / 100;

            if(area == arrayPoke[i].nPositionArea) {     //武将之间移动
                if(player != arrayPoke[i].nPositionPlayer) {
                    //arrayPoke[i].aniMoveTo(arrayPlayer[player].x, arrayPlayer[player].y)
                    arrayPoke[i].aniMoveTo(arrayPlayer[player].x + (Global.gamePos.mapPlayer.sizePlayerAvatar.width - Global.gamePos.paiWidth) / 2
                                           , arrayPlayer[player].y + (Global.gamePos.mapPlayer.sizePlayerAvatar.height - Global.gamePos.paiHeight) / 2)

                    arrayPoke[i].aniOpacity(1,0);
                    //arrayPoke[i].aniOpacity(0,1);
                    arrayPoke[i].delayHide(Global.config.nPaiDelayHide);

                }
            }
            else if(!(area == arrayPoke[i].nPositionArea     //出牌
                    && value == arrayPoke[i].nPositionValue
                    && player == arrayPoke[i].nPositionPlayer)) {
                createPokeToQiPaiDui(i);
                //arrayPoke[i].aniMoveTo(arrayPlayer[player].x, arrayPlayer[player].y)
                arrayPoke[i].aniOpacity(0,0);
                arrayPoke[i].moveTo(arrayPlayer[player].x, arrayPlayer[player].y);

                //arrayPoke[i].aniOpacity(1,0);
                //arrayPoke[i].aniOpacity(0,1);
                //arrayPoke[i].delayHide(500);
            }

            //refreshSmallZhuangBeiOrPanDing(i,area,value,player)
            //arrayPoke[i].iUsedPlayer = player;
            //arrayPoke[i].iUsedPosition = GameCore.pokeList[i].positionValue;
            //arrayPoke[i].aniOpacity(0,1);
            break;
        case PokeClass.Area_PaiDui:
            arrayPoke[i].bZhengMian = false;
            arrayPoke[i].bIsMine = false;
            arrayPoke[i].z = GameJS.Z_PaiDui + value / 100;
            arrayPoke[i].aniOpacity(0,0);
            arrayPoke[i].moveTo(Global.gamePos.posPaiDui.x,Global.gamePos.posPaiDui.y);

            break;
        case PokeClass.Area_QiPaiDui:
            arrayPoke[i].bZhengMian = true;
            arrayPoke[i].bIsMine = false;
            arrayPoke[i].z = GameJS.Z_PaiDui + value / 100;

            //arrayPoke[i].aniMoveTo(Global.gamePos.posQiPaiDui.x,Global.gamePos.posQiPaiDui.y);

            //原来在 弃牌堆 和 装备的 不再显示动画
            if(arrayPoke[i].nPositionArea == PokeClass.Area_QiPaiDui
                    || arrayPoke[i].nPositionArea == PokeClass.Area_ZhuangBei) {
            }
            else {
                if(!(area == arrayPoke[i].nPositionArea
                        && value == arrayPoke[i].nPositionValue
                        && player == arrayPoke[i].nPositionPlayer))   //只是刷新位置
                    createPokeToQiPaiDui(i);
                arrayPoke[i].aniOpacity(0,0);
            }
            arrayPoke[i].moveTo(Global.gamePos.posQiPaiDui.x,Global.gamePos.posQiPaiDui.y);

            break;
        }

        arrayPoke[i].nPositionArea = area;
        arrayPoke[i].nPositionValue = value;
        arrayPoke[i].nPositionPlayer = player;
    }

    //新建一个临时弃牌
    function createPokeToQiPaiDui(i) {
        //创建并与原牌绑定
        var tmp = compPoke.createObject(itemScale
                             ,{"nFlags": PokeClass.Flag_Enable
                                 , "width": Qt.binding(function(){return Global.gamePos.paiWidth})
                                 , "height": Qt.binding(function(){return Global.gamePos.paiHeight})
                                 //, "visible": true
                                 , "opacity": 1
                                 , "x": arrayPoke[i].x
                                 , "y": arrayPoke[i].y
                                 , "z": arrayPoke[i].z
                                , "bZhengMian": true
                                , "bRectangularGlow": true
                                 //, "vUserData": i
                             }
                             );
        setPokeImage(tmp,GameCore.pokeList[i].value);
        tmp.vUserData = tmp; //注意:这里vUserData为指针!!
        tmp.s_aniFinished.connect(onPokeAniFinished);
        mapQiPaiDui[tmp] = {"qiPaiIndex": Object.keys(mapQiPaiDui).length,  //加入Map,将对象地址作为key
            "qiPaiTmpObj": tmp};
        tmp.delayHide(Global.config.nQiPaiPaiDelayHide);  //展示3s
        refreshQiPaiQu();
        //console.debug("新建了一张牌:",tmp)
    }

    //临时弃牌 的动画结束,将之删除,并调整其余牌后 刷新弃牌区
    function onPokeAniFinished(aniType,pokeObj) {
        switch(aniType)
        {
        case 1:
            //console.debug("牌",pokeObj,"动画结束，共几个Key：",Object.keys(mapQiPaiDui).length)
            //console.debug("删除临时牌!")
            var index = mapQiPaiDui[pokeObj]["qiPaiIndex"];  //找到列表中的位置

            //删除临时牌和列表索引
            pokeObj.destroy();
            //mapQiPaiDui[pokeObj]["qiPaiTmpObj"] = undefined;
            //delete mapQiPaiDui[pokeObj]["qiPaiTmpObj"];
            delete mapQiPaiDui[pokeObj];

            for(var i in mapQiPaiDui) {
                /*
                if(mapQiPaiDui[i] == undefined) {
                    console.debug("undefined:",i)
                    for(var j in Object.keys(mapQiPaiDui)) {
                        console.debug("keys:",j)
                    }
                }*/
                //console.debug(i,pokeObj,mapQiPaiDui[i]["qiPaiIndex"]
                //              , mapQiPaiDui[pokeObj]["qiPaiIndex"])


                if(i == pokeObj) {
                    //console.debug("删除了一张牌:",mapQiPaiDui[i]["qiPaiTmpObj"]);
                }
                else if(mapQiPaiDui[i]["qiPaiIndex"] > index) {
                    //console.debug("重新Index前",mapQiPaiDui[i]["qiPaiIndex"]);
                    mapQiPaiDui[i]["qiPaiIndex"]--;
                    //console.debug("重新Index后",mapQiPaiDui[i]["qiPaiIndex"]);
                }
                else
                    continue;
            }
            refreshQiPaiQu();
            break;
        default:
            //console.debug("onPokeAniFinished Err!")
        }
    }

    //临时弃牌 的动画结束,将之删除,并调整其余牌后 刷新弃牌区
    function clearQiPaiQu() {

        //console.debug(Object.keys(mapQiPaiDui).length)
        for(var i in mapQiPaiDui) {
            //console.debug(i);
            mapQiPaiDui[i]["qiPaiTmpObj"].destroy();
            //i.destroy();  //Err
            //mapQiPaiDui[i]["qiPaiTmpObj"].vUserData.destroy();
        }
        mapQiPaiDui = {};
    }

    //刷新弃牌区
    function refreshQiPaiQu() {
        //最右边牌的x坐标(以paiduix为中点)
        var rightX = Global.gamePos.posQiPaiDui.x + (Object.keys(mapQiPaiDui).length - 2) * (Global.gamePos.paiWidth / 2)
        for(var i in mapQiPaiDui) {
            var tx = rightX - mapQiPaiDui[i]["qiPaiIndex"] * Global.gamePos.paiWidth;
            mapQiPaiDui[i]["qiPaiTmpObj"].aniMoveTo(tx,Global.gamePos.posQiPaiDui.y);

            /* 从右向左
            var tx = Global.gamePos.posQiPaiDui.x - mapQiPaiDui[i]["qiPaiIndex"] * Global.gamePos.paiWidth;
            mapQiPaiDui[i]["qiPaiTmpObj"].aniMoveTo(tx,Global.gamePos.posQiPaiDui.y);
            console.debug("重新排列",mapQiPaiDui[i]["qiPaiTmpObj"],"到",tx)*/
        }
    }

/*
    function setPokePos(i,dx,dy) {
        arrayPoke[i].x = dx;
        arrayPoke[i].y = dy;
        //arrayPoke[i].aniMoveTo(dx,dy)
    }*/


/*
    function setPlayerPixmap(i,pixmapSrc) {
        arrayPlayer[i].source = pixmapSrc;
    }
*/

    //设置小图标
    //i:牌下标；type: 1为设置,0为取消
    //全局参数：arrayPoke和iUsedPlayer(iUsedPlayer必须在设置前)
    function refreshSmallZhuangBeiOrPanDing(i,area,value,player) {  //参数为新位置
        //return;
        var p = GameCore.pokeList[i];
        //console.debug("refreshSmallZhuangBeiOrPanDing:",p,p.type,PokeClass.Type_YanChiJingNang)

        switch(p.type) {    //判断类型
        case PokeClass.Type_WuQi:
            //console.debug(arrayPoke[i].nPositionArea)
            if(arrayPoke[i].nPositionArea == PokeClass.Area_ZhuangBei) { //如果原来在装备区

                //if(arrayPoke[i].nPositionPlayer != player) { //上次装备的武将 和 此次装备武将不同
                    //console.debug(arrayPoke[i].iUsedPlayer,"卸下武器:",i)
                    //如果有装备，那就跳过卸下
                    if(GameCore.playerList[arrayPoke[i].nPositionPlayer].weaponCount == 0) { //如果原武将无装备了
                        if(arrayPoke[i].nPositionPlayer == nMyID)
                            myZhuangBei.visible = false;
                        else
                            arrayPlayer[arrayPoke[i].nPositionPlayer].pokeWeaponSmall.visible = false;
                    }
                //}
            }

            //console.debug(PokeClass.Area_ZhuangBei)
            if(area == PokeClass.Area_ZhuangBei) { //如果 现在 要去装备区

                //if(arrayPoke[i].nPositionPlayer != player) { //上次装备的武将 和 此次装备武将不同

                    if(player >= 0) { //目前装备的武将

                        if(player == nMyID) {    //玩家本人
                            myZhuangBei.pokeSource = getBigImage(p.value);

                            myZhuangBei.visible = true;
                            myZhuangBei.vUserData = i;
                            //console.debug("绑定:",i,myZhuangBei.vUserData)
                            myZhuangBei.nFlags = Qt.binding(function(){
                                return arrayPoke[i].nFlags;
                            })
                            //arrayPlayer[player].pokeWeaponSmall.move(-180,0)
                            //arrayPlayer[player].pokeWeaponSmall.pokeSource = getSmallImage(p.value)
                        }
                        else {
                            arrayPlayer[player].pokeWeaponSmall.moveTo(Global.dpW(-180),Global.gamePos.mapPlayer.rectZhuangBei.y);
                            arrayPlayer[player].pokeWeaponSmall.pokeSource = getSmallImage(p.value);

                            arrayPlayer[player].pokeWeaponSmall.visible = true;
                            arrayPlayer[player].pokeWeaponSmall.vUserData = i;

                            arrayPlayer[player].pokeWeaponSmall.nFlags = Qt.binding(function(){
                                return arrayPoke[i].nFlags;
                            })
                        }


                        //动画
                        if(player == nMyID) {
                            //console.debug("装备动画：",arrayPlayer[player].pokeWeaponSmall.x,arrayPlayer[player].pokeWeaponSmall.y,dstX,dstY);
                            //arrayPlayer[player].pokeWeaponSmall.aniMove(180,0)
                        }
                        else {
                            arrayPlayer[player].pokeWeaponSmall.aniMoveTo(Global.gamePos.mapPlayer.rectZhuangBei.x,Global.gamePos.mapPlayer.rectZhuangBei.y);
                        }

                        //console.debug(p.nPositionPlayer,"装备武器:",i)
                    }
                //}
            }

            break;
        case PokeClass.Type_FangJu:
            break;
        case PokeClass.Type_JiaMa:
            break;
        case PokeClass.Type_JianMa:
            break;
        case PokeClass.Type_YanChiJingNang:
            switch(p.value) {
            case PokeClass.Value_ShanDian:
            case PokeClass.Value_LeBuSiShu:

                if(arrayPoke[i].nPositionArea == PokeClass.Area_PanDing) { //如果原来在判定区
                    //if(arrayPoke[i].nPositionPlayer != player) { //上次装备的武将 和 此次装备武将不同
                    //if(arrayPoke[i].nPositionPlayer >= 0) { //上次装备的武将
                        //如果原牌的位置处有判定，那就跳过隐藏
                        if(GameCore.playerList[arrayPoke[i].nPositionPlayer].panDingList.length <= arrayPoke[i].nPositionValue) {
                            //console.debug("!!!player:",arrayPoke[i].nPositionPlayer,"area:",arrayPoke[i].nPositionArea,"value:",arrayPoke[i].nPositionValue,"i:",i)
                            if(arrayPoke[i].nPositionPlayer == nMyID)
                                itemMyItems.arrayPanDingSmall[arrayPoke[i].nPositionValue].visible = false;
                            else
                                arrayPlayer[arrayPoke[i].nPositionPlayer].arrayPanDingSmall[arrayPoke[i].nPositionValue].visible = false;
                        }
                        //console.debug("闪电取消:",arrayPoke[i].iUsedPlayer,arrayPoke[i].iUsedPosition)
                        //console.debug("看这里1:",p.iUsedPlayer)
                        //console.debug("看这里2:",arrayPoke[p.iUsedPlayer].iUsedPosition)
                    //}
                    //}
                }

                if(area == PokeClass.Area_PanDing) { //如果现在在判定区
                    if(player >= 0) { //目前装备的武将

                        //if(arrayPoke[i].nPositionPlayer != player) { //上次装备的武将 和 此次装备武将不同
                            //console.debug("!!!player:",player,"value:",value)

                            if(player == nMyID) {
                                //!!!这里也需要绑定!
                                var dstX = itemMyItems.arrayPanDingSmall[value].x;
                                var dstY = itemMyItems.arrayPanDingSmall[value].y;
                                itemMyItems.arrayPanDingSmall[value].moveTo(0,dstY);

                                itemMyItems.arrayPanDingSmall[value].pokeSource = getSmallImage(p.value);
                                itemMyItems.arrayPanDingSmall[value].visible = true;
                            }
                            else {
                                arrayPlayer[player].arrayPanDingSmall[value].pokeSource = getSmallImage(p.value);
                                arrayPlayer[player].arrayPanDingSmall[value].visible = true;
                            }
                            //console.debug("闪电:",arrayPoke[i].iUsedPlayer,arrayPoke[i].iUsedPosition);

                            if(player == nMyID) {
                                itemMyItems.arrayPanDingSmall[value].aniMoveTo(Global.gamePos.rectMyPanDing.x + value * Global.gamePos.nMyPanDingSpacing
                                                                                       ,Global.gamePos.rectMyPanDing.y);
                            }
                            else {
                                //console.debug("判定动画：",arrayPlayer[player].pokeWeaponSmall.x,arrayPlayer[player].pokeWeaponSmall.y,dstX,dstY);
                                //arrayPlayer[player].arrayPanDingSmall[value].aniMoveTo(Global.gamePos.rectMyPanDing.x + value * Global.gamePos.nMyPanDingSpacing
                                //                                                       ,Global.gamePos.rectMyPanDing.y);
                            }
                        //}
                    }
                }

                break;
            default:
                break;
            }
            break;
        default:
            //s_debugMsg("装一张牌错误！");
            break;
        }
    }

    //显示 玩家player 的所有区域
    function showPlayersPai(player) {
        //popupChoiceAreas.nPlayerShowed = player;
        //console.debug("player:",player)
        if(popupChoiceAreas.nPlayerShowed != -1) return;
        var i, p;

        //显示手牌
        for(i = 0; i < GameCore.playerList[player].shouPaiList.length; i++) {
            p = GameCore.playerList[player].shouPaiList[i];
            if(p.flags | PokeClass.Flag_Enable) {
                setPokeImage(popupChoiceAreas.arrayShouPai[i],p.value);
                popupChoiceAreas.arrayShouPai[i].vUserData = p.id;

                popupChoiceAreas.arrayShouPai[i].moveTo(
                            Global.gamePos.mapChoiceAreas.posChoiceAreas1.x + i * Global.gamePos.mapChoiceAreas.nChoiceAreasPokeSpacing
                            ,Global.gamePos.mapChoiceAreas.posChoiceAreas1.y);

                popupChoiceAreas.arrayShouPai[i].visible = true;
                //console.debug("绑定:",i,"到:",p.id)
                tmpBindChoiceAreasPai(popupChoiceAreas.arrayShouPai[i], p.id);
            }
        }
        for(; i < 20; i++) {
            popupChoiceAreas.arrayShouPai[i].visible = false;
        }

        var j = 0; //顺序

        //显示装备
        for(i = 0; i < GameCore.playerList[player].zhuangBeiList.length; i++) {
            j++;
            p = GameCore.playerList[player].zhuangBeiList[i];
            if(p.flags | PokeClass.Flag_Enable) {
                setPokeImage(popupChoiceAreas.arrayZhuangBei[i],p.value);
                popupChoiceAreas.arrayZhuangBei[i].vUserData = p.id;
                //popupChoiceAreas.arrayZhuangBei[i].moveTo(i * Global.gamePos.paiWidth, Global.gamePos.paiHeight + 10);

                popupChoiceAreas.arrayZhuangBei[i].moveTo(
                            Global.gamePos.mapChoiceAreas.posChoiceAreas2.x + j * Global.gamePos.mapChoiceAreas.nChoiceAreasPokeSpacing
                            ,Global.gamePos.mapChoiceAreas.posChoiceAreas2.y);

                popupChoiceAreas.arrayZhuangBei[i].visible = true;
                tmpBindChoiceAreasPai(popupChoiceAreas.arrayZhuangBei[i], p.id);
                //popupChoiceAreas.arrayZhuangBei[i].nFlags = Qt.binding(function(){
                //    return p.flags;
                //})
            }
        }
        for(; i < 4; i++) {
            popupChoiceAreas.arrayZhuangBei[i].visible = false;
        }

        //显示判定
        for(i = 0; i < GameCore.playerList[player].panDingList.length; i++) {
            p = GameCore.playerList[player].panDingList[i];
            j++;
            if(p.flags | PokeClass.Flag_Enable) {
                setPokeImage(popupChoiceAreas.arrayPanDing[i],p.value);
                popupChoiceAreas.arrayPanDing[i].vUserData = p.id;
                //popupChoiceAreas.arrayPanDing[i].moveTo(i * Global.gamePos.paiWidth,  (Global.gamePos.paiHeight + 10) * 2);

                popupChoiceAreas.arrayPanDing[i].moveTo(
                            Global.gamePos.mapChoiceAreas.posChoiceAreas2.x + j * Global.gamePos.mapChoiceAreas.nChoiceAreasPokeSpacing
                            ,Global.gamePos.mapChoiceAreas.posChoiceAreas2.y);

                popupChoiceAreas.arrayPanDing[i].visible = true;
                tmpBindChoiceAreasPai(popupChoiceAreas.arrayPanDing[i], p.id);
                //popupChoiceAreas.arrayPanDing[i].nFlags = Qt.binding(function(){
                //    return p.flags;
                //});
            }
        }
        for(; i < 2; i++) {
            popupChoiceAreas.arrayPanDing[i].visible = false;
        }
        popupChoiceAreas.show();
        popupChoiceAreas.nPlayerShowed = player; //保存,防止二次显示
        //console.debug("开开!")
    }

    //隐藏区域
    function hidePlayersArea() {
        /*
        if(popupChoiceAreas.nPlayerShowed == -1)return;
        var i, p;
        for(i = 0; i < GameCore.playerList[popupChoiceAreas.nPlayerShowed].shouPaiList.length; i++) {
            p = GameCore.playerList[popupChoiceAreas.nPlayerShowed].shouPaiList[i];
            setPokePosition(p.id,p.nPositionArea,p.nPositionValue,p.nPositionPlayer)
        }
        for(i = 0; i < GameCore.playerList[popupChoiceAreas.nPlayerShowed].panDi;
            p = GameCore.playerList[popupChoiceAreas.nPlayerShowed].panDingList[i].zhua[ionPlayer)
];ngList.length; i++) {
        }]        for(i = 0; i < GameCore.playerList[popupChoiceAreas.iPlayerShowep
                setPokePosition(p.id,p.nPositionArea,p.nPositionValue,p..lengthositidListe
            setPokePosition(p.id,p.nPositionArea,p.nPositionValue,p.positionPngBe;iy i++) {
            p = GameCore.playerList[popupChoiceAreas.nPlayerShowed].zhuangBeiListlar)
        }*/
        popupChoiceAreas.nPlayerShowed = -1;
        popupChoiceAreas.hide();
        //console.debug("灌灌!")
    }


    //每次游戏前初始化
    function init(playerCount,myID) {

        //msgBox.text = "<font size=10>---英语杀 By Pleafles---</font>"
        //shortMsg.text = ""
        if(GameCore.netPlay == false)   //聊天
            imageMsg.visible = false;
        else
            imageMsg.visible = true;

        popupGameOver.visible = false;
        msgBox.textArea.text = "";
        textChuPaiMsg.text = "游戏开始中";

        console.log("!init:",playerCount,myID);
        nMyID = myID;
        nPlayerCount = playerCount;
        setPlayersPos();

        var i;
        for(i = 0;i < playerCount; i++) {
            //setPlayerFlags(i,PokeClass.Flag_Null);
            updatePlayerFlags(i);
            arrayPlayer[i].visible = true;
            //arrayPlayer[i].bDead = false;
            arrayPlayer[i].z = GameJS.Z_Player;
            /*
            if(i == nMyID) {
                if(UserInfo.sex == 1)
                    arrayPlayer[i].source = Global._FixResourcePath_R("Media/Images/Persons/LiLei.png");
                else
                    arrayPlayer[i].source = Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png");

                //arrayPlayer[i].pokeWeaponSmall.x = Global.gamePos.rectZhuangBei.x
                //arrayPlayer[i].pokeWeaponSmall.y = Global.gamePos.rectZhuangBei.y
                //arrayPlayer[i].pokeWeaponSmall.width = Global.gamePos.rectZhuangBei.width
                //arrayPlayer[i].pokeWeaponSmall.height = Global.gamePos.rectZhuangBei.height
            }
            else {
                if(Math.random() < 0.5)
                    arrayPlayer[i].source = Global._FixResourcePath_R("Media/Images/Persons/LiLei.png");
                else
                    arrayPlayer[i].source = Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png");
                //arrayPlayer[i].pokeWeaponSmall.x = arrayPlayer[i].x + Global.dpW(22)
                //arrayPlayer[i].pokeWeaponSmall.y = arrayPlayer[i].y + Global.dpH(94)
                //arrayPlayer[i].pokeWeaponSmall.width = Global.gamePos.sizeOthersZhuangBei.width
                //arrayPlayer[i].pokeWeaponSmall.height = Global.gamePos.sizeOthersZhuangBei.height
            }
            */
        }

        //初始化头像图片,牌图片
        for(; i < nPlayerMaxCount; i++) {
            arrayPlayer[i].visible = false;
        }
        //refreshAllPlayersFlags();


        for(i = 0; i < nPokeMaxCount; i++) {
            //arrayPoke[i].nFlags = PokeClass.Flag_Enable
            arrayPoke[i].bIsMine = false;
            //arrayPoke[i].visible = true;
            arrayPoke[i].bZhengMian = false;
            arrayPoke[i].moveTo(Global.gamePos.posPaiDui.x, Global.gamePos.posPaiDui.y);
            arrayPoke[i].aniOpacity(0,0);
            arrayPoke[i].z = GameJS.Z_ShouPai;
            //arrayPoke[i].moveAni.stop()

            //setPokePosition(i,PokeClass.Area_Null,-1,-1)
            //setPokeFlags(i,PokeClass.Flag_Null);
            updatePokeFlags(i);
            updatePokePosition(i);

            //arrayPoke[i].iUsedPlayer = -1;
            //arrayPoke[i].iUsedPosition = -1;
            //arrayPoke[i].iUsedPositionValue = -1;
        }
        //refreshAllPokesPosition();
        //refreshAllPokesFlags();



        playlist.next();
        if(Global.config.bMusicOn)
            _audio.play();

        timerPublic.start();
        //GameCore.sl_UserActionFinished()

        console.log("!init over");
    }

    /*
    onClosing: {
        console.debug("!exit")
        //close.accepted = false

    }
    */


    function setPokeImage(poke,value) {
        switch(value) {
        case PokeClass.Value_Sha:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai101.png");
            break;
        case PokeClass.Value_Shan:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai102.png");
            break;
        case PokeClass.Value_Tao:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai103.png");
            break;
        case PokeClass.Value_Chai:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai201.png");
            break;
        case PokeClass.Value_Shun:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai202.png");
            break;
        case PokeClass.Value_WuZhong:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai203.png");
            break;
        case PokeClass.Value_JieDao:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai204.png");
            break;
        case PokeClass.Value_NanMan:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai205.png");
            break;
        case PokeClass.Value_WanJian:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai206.png");
            break;
        case PokeClass.Value_GaoKao:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai207.png");
            break;
        case PokeClass.Value_LeBuSiShu:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai301.png");
            break;
        case PokeClass.Value_ShanDian:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai302.png");
            break;
        case PokeClass.Value_LianNu:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai401.png");
            break;
        case PokeClass.Value_ZhangBa:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai402.png");
            break;
        case PokeClass.Value_QingLong:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai403.png");
            break;
        case PokeClass.Value_GuanShiFu:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai404.png");
            break;
        case PokeClass.Value_HanBing:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai405.png");
            break;
        case PokeClass.Value_TanSu:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/Pai406.png");
            break;
        default:
            poke.pokeSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/PaiErr.png");
            break;
        }
        poke.pokeBackSource = Global._FixResourcePath_R("Media/Images/Game/Pokes/PaiBack.png");
    }

    function getSmallImage(v) {
        switch(v) {
        case PokeClass.Value_ShanDian:
            return Global._FixResourcePath_R("Media/Images/Game/JingNang/TuoFu.png");
        case PokeClass.Value_LeBuSiShu:
            return Global._FixResourcePath_R("Media/Images/Game/JingNang/CuoGuoKaoShi.png");
        case PokeClass.Value_LianNu:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Small/ZiDongBi.png");
        case PokeClass.Value_ZhangBa:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Small/MaoBi.png");
        case PokeClass.Value_QingLong:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Small/GangBi.png");
        case PokeClass.Value_GuanShiFu:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Small/YuanZhuBi.png");
        case PokeClass.Value_HanBing:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Small/QianBi.png");
        case PokeClass.Value_TanSu:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Small/TanSuBi.png");
        default:
            s_debugMsg("错牌");
        }
    }

    function getWuJiangImage(v) {
        switch(v) {
        case WuJiangClass.Value_LiLei:
            return Global._FixResourcePath_R("Media/Images/Persons/LiLei.png")
        case WuJiangClass.Value_HanMeiMei:
            return Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png");
        case WuJiangClass.Value_NiuDun:
            return Global._FixResourcePath_R("Media/Images/Persons/LiLei.png")
        case WuJiangClass.Value_GeLunBu:
            return Global._FixResourcePath_R("Media/Images/Persons/LiLei.png");
        case WuJiangClass.Value_YaLiShanDa:
            return Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png")
        case WuJiangClass.Value_DanDing:
            return Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png");
        case WuJiangClass.Value_ChengJiSiHan:
            return Global._FixResourcePath_R("Media/Images/Persons/LiLei.png")
        case WuJiangClass.Value_NaPoLun:
            return Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png");
        case WuJiangClass.Value_DaFenQi:
            return Global._FixResourcePath_R("Media/Images/Persons/LiLei.png")
        case WuJiangClass.Value_KaiSa:
            return Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png");
        case WuJiangClass.Value_AYuWang:
            return Global._FixResourcePath_R("Media/Images/Persons/LiLei.png")
        case WuJiangClass.Value_ChengDuXiu:
            return Global._FixResourcePath_R("Media/Images/Persons/HanMeiMei.png");
        default:
            s_debugMsg("神马武将");
            return "";
        }
    }
    function getBigImage(v) {
        switch(v) {
        case PokeClass.Value_LianNu:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Big/ZiDongBi.png");
        case PokeClass.Value_ZhangBa:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Big/MaoBi.png");
        case PokeClass.Value_QingLong:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Big/GangBi.png");
        case PokeClass.Value_GuanShiFu:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Big/YuanZhuBi.png");
        case PokeClass.Value_HanBing:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Big/QianBi.png");
        case PokeClass.Value_TanSu:
            return Global._FixResourcePath_R("Media/Images/Game/Weapons/Big/TanSuBi.png");
        default:
            s_debugMsg("错牌");
        }
    }

    function getPlayerPos(player) {
        if(player != nMyID) {
            return Qt.point(arrayPlayer[player].x + arrayPlayer[player].width / 2,
                            arrayPlayer[player].y + arrayPlayer[player].height / 2);
        }
        else {
            return Qt.point(Global.gamePos.posPaiQu.x,
                            Global.gamePos.posPaiQu.y);
        }
    }



    //绑定 ChoiceAreas 到 某张牌
    function tmpBindChoiceAreasPai(pai, n) {

        pai.nFlags = Qt.binding(function(){
            //console.debug("牌id:",n,"nFlags:",arrayPoke[n].nFlags)
            return arrayPoke[n].nFlags;
            //return GameCore.playerList[player].shouPaiList[i].flags;
            //return p.flags;
        })
    }

    //创建一张牌,并绑定信号槽
    function tmpCreatePoke(n) {

        arrayPoke[n] = compPoke.createObject(itemScale,{
                                                 "nFlags": PokeClass.Flag_Null
                                                 , "width": Qt.binding(function(){return Global.gamePos.paiWidth})
                                                 , "height": Qt.binding(function(){return Global.gamePos.paiHeight})
                                                 , "bBiggerEnabled": true
                                             });
        GameCore.pokeList[n].flagsChanged.connect(function(flags){
            //console.debug("qml poke flags changed:",flags)
            //setPokeFlags(flags);
        })

        GameCore.pokeList[n].positionChanged.connect(function() {
            setPokePosition(n,GameCore.pokeList[n].positionArea,GameCore.pokeList[n].positionValue,GameCore.pokeList[n].positionPlayer);
        });

    }
    //创建一个玩家,并绑定信号槽
    function tmpCreatePlayer(n) {

        arrayPlayer[n] = compPlayer.createObject(itemScale,{
                                                     "nFlags": PokeClass.Flag_Null
                                                     ,"width": Qt.binding(function(){return Global.gamePos.mapPlayer.sizePlayerAvatar.width})
                                                     ,"height": Qt.binding(function(){return Global.gamePos.mapPlayer.sizePlayerAvatar.height})
                                                     ,"bDead": Qt.binding(function(){return GameCore.playerList[n].dead})
                                                 });

        GameCore.playerList[n].flagsChanged.connect(function(flags){
            //console.debug("qml player flags changed:",flags);
            //setPlayerFlags(id,flags);
        });

        GameCore.playerList[n].deadChanged.connect(function(dead){
            if(dead == true) {
                arrayPlayer[n].pokeWeaponSmall.visible = false;    //结束后必须全部隐藏
                for(var j = 0; j < arrayPlayer[n].arrayPanDingSmall.length; j++) {
                    arrayPlayer[n].arrayPanDingSmall[j].visible = false;
                }
            }
        });

        GameCore.playerList[n].s_SetBlood.connect(function(blood,maxBlood){
            //console.debug("qml player flags changed:",type,flags);
            arrayPlayer[n].setBlood(blood,maxBlood);
        });

        GameCore.playerList[n].s_RefreshBlood.connect(function(blood){
            //console.debug("qml player flags changed:",type,flags);
            arrayPlayer[n].refreshBlood(blood);
        });

        GameCore.playerList[n].s_qml_RefreshWuJiang.connect(function(){
            arrayPlayer[n].source = getWuJiangImage(GameCore.playerList[n].wuJiangValue);
            //arrayPlayer[].initJiNeng();
            //console.debug("initJiNeng Over")
        });

        GameCore.playerList[n].s_ShouPaiShu.connect(function(count){
            //console.debug("qml player flags changed:",type,flags);
            arrayPlayer[n].nShouPaiCount = count;
        });
    }

    QtObject {
        id: _private
/*
        //游戏元素 鼠标放上去发亮效果
        property ColorOverlay colorOverlay:
        //颜色遮罩(不可用时黑色,source必须和本对象同一层次!!!)
        ColorOverlay {
            //id: colorOverlay
            visible: false
            //anchors.fill: imageStudy;
            //source: imageStudy;
            color: "#40FFFFFF"
            parent: gameWindow
        }

        //显示在image上
        function showColorOverlay(image) {
            colorOverlay.anchors.fill = image;
            colorOverlay.source = image;
            colorOverlay.visible = true;

        }
        //隐藏
        function hideColorOverlay() {
            colorOverlay.visible = false;
        }
*/

        function drawLines(lineList) {
            var i = 0, j, k = 0;
            var x1,y1,x2,y2;
            //console.debug("linelist:",lineList.length)
            while(i < lineList.length) {
                x1 = getPlayerPos(lineList[i]).x;
                y1 = getPlayerPos(lineList[i]).y;
                //console.debug("!!!!!!!!!",arrayPlayer[lineList[i]].width)

                //一对多
                if(lineList[i+1] == -1) {
                    for(j = 0; j < gameWindow.nPlayerCount; j++) {
                        if(lineList[i] != j && GameCore.playerList[j].dead == false) {//arrayPlayer[j].bDead == false) {
                            x2 = getPlayerPos(j).x;
                            y2 = getPlayerPos(j).y;
                            arrayLine[k].srcPoint = Qt.point(x1, y1)
                            arrayLine[k].dstPoint = Qt.point(x2, y2)
                            arrayLine[k].visible = true;
                            arrayLine[k].aniDraw();
                            k++;
                        }
                    }
                    break;
                }

                //一对一
                else {
                    arrayLine[k].srcPoint = Qt.point(x1, y1);
                    x2 = getPlayerPos(lineList[i+1]).x;
                    y2 = getPlayerPos(lineList[i+1]).y;
                    arrayLine[k].dstPoint = Qt.point(x2, y2);
                    arrayLine[k].visible = true;
                    arrayLine[k].aniDraw();
                    k++;
                    //console.debug("canvas:",x1,y1,i,x2,y2)
                }

                //console.debug("lineList::",lineList[i],lineList[i+1])
                i += 2;

            }
            timerLineHide.start();
        }

        function getPokeTips(v) {
            switch(v) {
            case PokeClass.Value_Sha:
                return qsTr("考试：出牌阶段，对你攻击范围内的一名其他角色使用。你对该角色造成1点伤害。");
            case PokeClass.Value_Shan:
                return qsTr("解答：以你为目前的考试生效前，对此考试使用。抵消此【考试】。");
            case PokeClass.Value_Tao:
                return qsTr("答案：出牌阶段，对已受伤的你使用，令你回复1点体力；当一名角色处于濒死状态时，对该角色使用，令其回复1点体力。");
            case PokeClass.Value_Chai:
                return qsTr("拆书：出牌阶段，对任意有牌的其他角色使用。你将其区域内的一张牌弃置。发动技能前选择正确单词才可生效。");
            case PokeClass.Value_Shun:
                return qsTr("借笔记：出牌阶段，对任意有牌的其他角色使用。你获得其区域内的一张牌。发动技能前选择正确单词才可生效。");
            case PokeClass.Value_WuZhong:
                return qsTr("发新书：出牌阶段，对自己使用，选择正确单词摸两张牌。");
            case PokeClass.Value_JieDao:
                return qsTr("借笔考试：出牌阶段，对装备区里有武器牌的一名其他角色使用。该角色需对其攻击范围内，由你指定的另一名角色使用一张【考试】，否则将装备区里的武器牌交给你。选择正确单词技能才会发动。");
            case PokeClass.Value_NanMan:
                return qsTr("四级：出牌阶段，对所有其他角色使用。每名目标角色需打出一张【考试】，否则受到1点伤害。发动技能前选择正确单词才可生效。");
            case PokeClass.Value_WanJian:
                return qsTr("六级：出牌阶段，对所有其他角色使用。每名目标角色需打出一张【解答】，否则受到1点伤害。发动技能前选择正确单词才可生效。");
            case PokeClass.Value_GaoKao:
                return qsTr("高考：对任意角色使用此牌，目标角色需对单词做出正确选择，若选择错误造成1点伤害。");
            case PokeClass.Value_LeBuSiShu:
                return qsTr("错过考试：出牌阶段，对一名其他角色使用。待目标角色出牌时，目标角色需选择正确单词，选择错误目标角色将跳过此次出牌阶段。");
            case PokeClass.Value_ShanDian:
                return qsTr("托福：出牌阶段，对自己使用。判定阶段回答一次问题，选择错误造成2点伤害，此牌置弃牌堆；若是回答正确，此牌转移到下一在场角色。");
            case PokeClass.Value_LianNu:
                return qsTr("自动笔：攻击范围1，出牌阶段，你可以使用任意数量的【考试】。");
            case PokeClass.Value_ZhangBa:
                return qsTr("毛笔：攻击范围3，你可以将两张手牌当【考试】使用或打出。");
            case PokeClass.Value_QingLong:
                return qsTr("钢笔：攻击范围3，当你使用的【考试】被【解答】抵消时，你可以对相同的目标再使用一张【考试】。");
            case PokeClass.Value_GuanShiFu:
                return qsTr("圆珠笔：攻击范围2，当你使用的【考试】被抵消时，你可以弃置两张牌，则此【考试】依然造成伤害。");
            case PokeClass.Value_HanBing:
                return qsTr("铅笔：攻击范围2，当你使用【考试】对目标角色造成伤害时，若该角色有牌，你可以防止此伤害，改为依次弃置其两张牌。");
            case PokeClass.Value_TanSu:
                return qsTr("碳素笔：攻击范围2 ，你可以将两张【考试】同时打出，若是对方没有任何【解答】对目标造成2点伤害。");
            default:
                return qsTr("这是一张神马牌?!");
            }
        }
    }


    /*
    Keys.onEscapePressed:  {
        event.accepted = true;
        changeGameEscMenuVisible();
    }*/

    Component.onCompleted: {
    }

    /*
    function test()
    {
        console.debug("test qml")
    }
    Poke {
    //z:100
        pokeSource : "Pai101.jpg"
        pokeBackSource : "PaiBei.jpg"
        nFlags : PokeClass.Flag_Show | PokeClass.Flag_Enable | PokeClass.Flag_ZhengMian
    }*/
}
